<template>
	<view @click="hide">
		<u-popup v-model="showpopup" mode="bottom">
			<view class="center">
				<view class="item">
					<image src="https://peonyoss.longchimudan.com/peony/goods/30c89dc0e26a4dbcb3800dc087e65bf1.jpg" class="img"></image>
					<view class="item-titel">
						<view class="item-price">￥15.00</view>
						<view class="item-Spec">规格: 150g</view>
					</view>
				</view>
				<view class="title">规格</view>
				<view class="Spec">150g</view>
				<view class="item-quantity">
					<view class="quantity">
						<view class="title">
							数量
							<view class="title-quantity">（库存8963）</view>
						</view>
					</view>
					<view class="select"><u-number-box v-model="value" @change="valChange"></u-number-box></view>
				</view>
				<view class="bottom-button">
					<button  class="button-left" @click="onaddcart">加入购物车</button>
					<button class="button-right" @click="onpayment">立即购买</button>
				</view>
				<view class="close" @click="hide"><u-icon name="close-circle" size="34"></u-icon></view>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			showpopup: false,
			value: 0
		};
	},
	methods: {
		//显示
		show() {
			this.showpopup = true;
		},
//隐藏
		hide() {
			this.showpopup = false;
		},
		valChange(e) {
			console.log('当前值为: ' + e.value);
		},
		//立即购买
		onpayment(){
			uni.navigateTo({
				url:'/pages/submit-order/index'
			})
			console.log('立即购买')
		},
		//加入购物车
		onaddcart(){
			uni.switchTab({
				url:'/pages/cart/index'
			})
			console.log('加入购物车')
		}
	}
};
</script>

<style lang="scss">
@import '@/styles/mixin.scss';
.center {
	width: 100%;
	padding: 40rpx;
	height: 921rpx;
	background: #ffffff;
	.item {
		display: flex;
		flex-direction: row;
		.img {
			width: 176rpx;
			height: 178rpx;
		}
		.item-titel {
			padding: 20rpx;
			.item-price {
				font-size: 46rpx;
				font-weight: bold;
				color: #f53942;
			}
			.item-spec {
				font-size: 24rpx;
				font-weight: 400;
				color: #888888;
			}
		}
	}
	.title {
		display: inline-block;
		font-size: 26rpx;
		font-weight: 400;
		color: #222222;
	}
	.Spec {
		display: inline-block;
		background: #f6f6f6;
		border-radius: 5px;
	}
	.item-quantity {
		width: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		.quantity {
			.title {
				display: flex;
				font-size: 26rpx;
				font-weight: 400;
				color: #222222;
			}
			.title-quantity {
				font-size: 26rpx;
				font-weight: 400;
				color: #888888;
			}
		}
		.select {
		}
	}

	.bottom-button {
		width: 100%;
		position: fixed;
		bottom: 0;
		.button-left {
			width: 320rpx;
			height: 78rpx;
			background: #f5b539;
			font-weight: bold;
			font-size: 28rpx;
			color: #f2f2f2;
			border-radius: 39rpx 0 0 39rpx;
		}
		.button-right {
			width: 320rpx;
			font-weight: bold;
			font-size: 28rpx;
			color: #f2f2f2;
			border-radius: 0 39rpx 39rpx 0;
			height: 78rpx;
			background: #f53942;
		}
	}
	.close {
		padding: 20rpx;
		position: fixed;
		top: 0;
		right: 0;
	}
}
</style>
